package com.learn.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

public class ThreadPoolTest {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        FutureTask futureTask = new FutureTask(new ThreadCallable());
        Thread thread = new Thread(futureTask);
        executorService.submit(thread);
        executorService.shutdown();
    }

}

class ThreadCallable implements Callable{

    public Object call() throws Exception {
        int num=0;
        for (int i=0;i<100;i++){
            if (i%2==0){
                Thread.sleep(10);
                System.out.println(Thread.currentThread().getName()+":"+i);
                num+=i;
            }
        }
        return num;
    }
}